/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package co.edu.univalle.persistencia;

import co.edu.univalle.modelo.Cuentas;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

/**
 *
 * @author DILOVE
 */
@Stateless
public class CuentaDAO implements ICuentaDAO {
    @PersistenceContext
    private EntityManager entityManager;
    
    @Override
    public void registrar(Cuentas cuenta) {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public void modificar(Cuentas cuenta) {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public void eliminar(Cuentas cuenta) {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public List<Cuentas> consultar() {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public Cuentas consultarPorCodigo(String numero) {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public List<Cuentas> consultarCuentasCliente(Long cedula) {
        try{
            String consulta = "select c from Cuentas c where cliCedula.cliCedula="+cedula;
            Query query = entityManager.createQuery(consulta);
            return query.getResultList();
        }catch(RuntimeException e){
            throw e;
        }
    }

    @Override
    public List<Cuentas> consultarCuentasActivas() {
        try{
        String consulta = "Select c from Cuentas c where c.cueActiva='S'";
        Query query = entityManager.createQuery(consulta);
        return query.getResultList();
        }catch(RuntimeException e)
        {
            throw e;
        }
    }

    // Add business logic below. (Right-click in editor and choose
    // "Insert Code > Add Business Method")
}
